package com.example.utils;

import com.example.vo.ExamPaperPackageDetailVO;

import java.util.ArrayList;
import java.util.List;

public class ExamPaperPackageUtils {

    public static List<ExamPaperPackageDetailVO> getExamPaperPackages() {
        List<ExamPaperPackageDetailVO> examPaperPackageDetailVOS = new ArrayList<>();

        // 定义学院和专业方向数据
        String[][] data = {
                {"计算机学院", "101", "计算机", "201", "软件工程", "301", "嵌入式方向"},
                {"计算机学院", "101", "计算机", "202", "网络工程", "302", "云计算方向"},
                {"计算机学院", "101", "计算机", "203", "人工智能", "303", "深度学习"},
                {"计算机学院", "101", "计算机", "204", "大数据", "304", "数据挖掘"},
                {"计算机学院", "101", "计算机", "205", "网络工程", "304", "网络安全"}


        };

        // 试题数据
        String[][] questionData = {
                {"radio", "下列哪项是Java的关键字？", "C", "Java,关键字", "Java中的关键字是保留的，不能作为变量名使用。", "[{\"A\":\"include\"},{\"B\":\"define\"},{\"C\":\"class\"}]", "1"},
                {"checkbox", "以下哪些是Java的基本数据类型？", "A,B,D", "Java,基本数据类型", "Java中包括int、double等数据类型。", "[{\"A\":\"int\"},{\"B\":\"double\"},{\"C\":\"string\"},{\"D\":\"boolean\"}]", "1"},
                {"judge", "Java是面向对象的编程语言。", "true", "Java,面向对象", "Java是一种面向对象的高级编程语言。", "[]", "2"},
                {"radio", "TCP/IP协议簇中属于传输层的是哪一个？", "C", "TCP/IP,传输层", "传输层协议包括TCP和UDP。", "[{\"A\":\"HTTP\"},{\"B\":\"DNS\"},{\"C\":\"TCP\"}]", "2"},
                {"checkbox", "以下哪些是TCP/IP协议簇中的应用层协议？", "A,B,D", "TCP/IP,协议", "常见的应用层协议包括HTTP、FTP、DNS等。", "[{\"A\":\"HTTP\"},{\"B\":\"FTP\"},{\"C\":\"IP\"},{\"D\":\"DNS\"}]", "1"},
                {"radio", "Java中的集合类HashMap是线程安全的吗？", "B", "Java,集合类", "HashMap不是线程安全的，应该使用ConcurrentHashMap。", "[{\"A\":\"是\"},{\"B\":\"否\"}]", "3"},
                {"checkbox", "Java中哪个包用于处理日期和时间？", "A,C", "Java,日期时间", "处理日期和时间的包是java.util和java.time。", "[{\"A\":\"java.util\"},{\"B\":\"java.io\"},{\"C\":\"java.time\"}]", "1"},
                {"judge", "ArrayList是线程安全的。", "false", "Java,线程安全", "ArrayList不是线程安全的。", "[]", "2"},
                {"radio", "Java中，字符串的不可变性是由什么实现的？", "A", "Java,字符串", "Java的字符串是不可变的，这意味着它们不能被修改。", "[{\"A\":\"String类\"},{\"B\":\"StringBuffer类\"},{\"C\":\"StringBuilder类\"}]", "3"},
                {"checkbox", "以下哪些操作属于Java集合框架的操作？", "A,B,D", "Java,集合框架", "Java集合框架提供了操作集合的丰富API，如add(),remove(),contains()等。", "[{\"A\":\"add\"},{\"B\":\"remove\"},{\"C\":\"append\"},{\"D\":\"contains\"}]", "1"},
                {"radio", "TCP协议是面向无连接的协议吗？", "B", "TCP/IP,协议", "TCP是面向连接的，而UDP是面向无连接的协议。", "[{\"A\":\"是\"},{\"B\":\"否\"}]", "2"},
                {"checkbox", "HTTP协议中的请求方法有哪些？", "A,C,D", "HTTP,请求方法", "HTTP协议常见的请求方法包括GET、POST、PUT等。", "[{\"A\":\"GET\"},{\"B\":\"DELETE\"},{\"C\":\"POST\"},{\"D\":\"PUT\"}]", "1"},
                {"radio", "在Java中，如何获取数组的长度？", "A", "Java,数组", "在Java中，可以通过array.length来获取数组的长度。", "[{\"A\":\"array.length\"},{\"B\":\"array.size()\"},{\"C\":\"array.size\"}]", "1"},
                {"checkbox", "下列哪些是Java常见的异常类型？", "A,B,C", "Java,异常", "Java常见的异常类型包括NullPointerException、ArrayIndexOutOfBoundsException等。", "[{\"A\":\"NullPointerException\"},{\"B\":\"ArrayIndexOutOfBoundsException\"},{\"C\":\"ArithmeticException\"},{\"D\":\"IOException\"}]", "2"},
                {"judge", "Java中的接口可以有构造方法。", "false", "Java,接口", "接口不能有构造方法。", "[]", "3"},
                {"radio", "Java中，String和StringBuffer的区别是什么？", "A", "Java,字符串", "String是不可变的，而StringBuffer是可变的。", "[{\"A\":\"String不可变\"},{\"B\":\"StringBuffer不可变\"}]", "2"},
                {"checkbox", "以下哪些是Java中的集合类？", "A,B,C", "Java,集合类", "Java中的集合类包括ArrayList、HashMap和HashSet等。", "[{\"A\":\"ArrayList\"},{\"B\":\"HashMap\"},{\"C\":\"HashSet\"},{\"D\":\"TreeSet\"}]", "1"},
                {"radio", "Java中，哪种类型的数据是值类型？", "C", "Java,数据类型", "Java中的基本数据类型（如int、float等）是值类型。", "[{\"A\":\"Object\"},{\"B\":\"String\"},{\"C\":\"int\"}]", "1"},
                {"checkbox", "Java中的集合类HashMap如何存储数据？", "A,B", "Java,集合类", "HashMap通过键值对的方式存储数据，且键不可重复。", "[{\"A\":\"键值对\"},{\"B\":\"无序存储\"},{\"C\":\"有序存储\"}]", "2"},
                {"judge", "Java中的ArrayList是线程安全的。", "false", "Java,线程安全", "ArrayList是非线程安全的。", "[]", "3"}
        };

        // 创建试题包及其试题
        for (int i = 0; i < data.length; i++) {
            ExamPaperPackageDetailVO packageVO = new ExamPaperPackageDetailVO();
            packageVO.setId(1000 + i + 1);
            packageVO.setPackName("试题包" + (i + 1));
            packageVO.setVersion("1.0");
            packageVO.setIsPublic(0);
            packageVO.setBusiTypeId1(Integer.parseInt(data[i][1]));
            packageVO.setBusiTypeName1(data[i][0]);
            packageVO.setBusiType1(data[i][2]);
            packageVO.setBusiTypeId2(Integer.parseInt(data[i][3]));
            packageVO.setBusiTypeName2(data[i][4]);
            packageVO.setBusiTypeId3(Integer.parseInt(data[i][5]));
            packageVO.setBusiTypeName3(data[i][6]);

            // 创建试题
            List<ExamPaperPackageDetailVO.Question> questions = new ArrayList<>();
            for (int j = 0; j < questionData.length; j++) {
                ExamPaperPackageDetailVO.Question question = new ExamPaperPackageDetailVO.Question();
                question.setId(10000 + (i + 1) * 100 + j + 1);
                question.setVersion("1.0");
                question.setQuestionType(questionData[j][0]); // radio, checkbox, judge
                question.setBusiTypeId1(data[i][1]);
                question.setBusiTypeName1(data[i][0]);
                question.setBusiType1(data[i][2]);
                question.setBusiTypeId2(data[i][3]);
                question.setBusiTypeName2(data[i][4]);
                question.setBusiTypeId3(data[i][5]);
                question.setBusiTypeName3(data[i][6]);
                question.setQsContent(questionData[j][1]); // 题面
                question.setQsCorrectAns(questionData[j][2]); // 正确答案
                question.setKeyword(questionData[j][3]); // 关键字
                question.setAnalysis(questionData[j][4]); // 解析
                question.setCorrectAnsJson(questionData[j][5]); // 选项 JSON 串
                question.setLevel(questionData[j][6]); // 设置等级
                question.setStatus("0"); // 正常状态
                questions.add(question);
            }

            packageVO.setQuestions(questions);
            examPaperPackageDetailVOS.add(packageVO);
        }

        return examPaperPackageDetailVOS;
    }
}
